/*
 * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
 *
 *  企业用户未经smartboot组织特别许可，需遵循AGPL-3.0开源协议合理合法使用本项目。
 *
 *  Enterprise users are required to use this project reasonably
 *  and legally in accordance with the AGPL-3.0 open source agreement
 *  without special permission from the smartboot organization.
 */

package com.smartboot.plus.plugins;

import com.alibaba.fastjson2.annotation.JSONField;

import java.util.List;


/**
 * @author 三刀
 * @version v1.0 4/27/25
 */

public class PluginConfig {
    private boolean enabled = true;

    @JSONField(name = "openApi")
    private HttpConfig httpConfig;

    @JSONField(name = "database")
    private DataBaseConfig dataBaseConfig;


    @JSONField(name = "cluster")
    private ClusterConfig clusterConfig;


    @JSONField(name = "auth")
    private AuthConfig authConfig;


    @JSONField(name = "user")
    private UserConfig userConfig;
    @JSONField(name = "node")
    private NodeConfig nodeConfig;
    private String registry;
    /**
     *
     */
    private String nodeType;

    /**
     * 连接的核心节点ID
     */
    private String coreNodeId;

    /**
     * 作为协调节点开放的集群访问地址
     */
    private String clusterEndpoint;

    public HttpConfig getHttpConfig() {
        return httpConfig;
    }

    public void setHttpConfig(HttpConfig httpConfig) {
        this.httpConfig = httpConfig;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public String getRegistry() {
        return registry;
    }

    public void setRegistry(String registry) {
        this.registry = registry;
    }

    public String getNodeType() {
        return nodeType;
    }

    public void setNodeType(String nodeType) {
        this.nodeType = nodeType;
    }

    public String getCoreNodeId() {
        return coreNodeId;
    }

    public void setCoreNodeId(String coreNodeId) {
        this.coreNodeId = coreNodeId;
    }

    public String getClusterEndpoint() {
        return clusterEndpoint;
    }

    public void setClusterEndpoint(String clusterEndpoint) {
        this.clusterEndpoint = clusterEndpoint;
    }

    public DataBaseConfig getDataBaseConfig() {
        return dataBaseConfig;
    }

    public void setDataBaseConfig(DataBaseConfig dataBaseConfig) {
        this.dataBaseConfig = dataBaseConfig;
    }

    public AuthConfig getAuthConfig() {
        return authConfig;
    }

    public void setAuthConfig(AuthConfig authConfig) {
        this.authConfig = authConfig;
    }


    public NodeConfig getNodeConfig() {
        return nodeConfig;
    }

    public void setNodeConfig(NodeConfig nodeConfig) {
        this.nodeConfig = nodeConfig;
    }


    public ClusterConfig getClusterConfig() {
        return clusterConfig;
    }

    public void setClusterConfig(ClusterConfig clusterConfig) {
        this.clusterConfig = clusterConfig;
    }



    public UserConfig getUserConfig() {
        return userConfig;
    }

    public void setUserConfig(UserConfig userConfig) {
        this.userConfig = userConfig;
    }

    public static class HttpConfig {
        private String host;
        private int port = 18083;
        private int readBufferSize = 1024 * 8;

        public String getHost() {
            return host;
        }

        public void setHost(String host) {
            this.host = host;
        }

        public int getPort() {
            return port;
        }

        public void setPort(int port) {
            this.port = port;
        }

        public int getReadBufferSize() {
            return readBufferSize;
        }

        public void setReadBufferSize(int readBufferSize) {
            this.readBufferSize = readBufferSize;
        }
    }

    public static  class DataBaseConfig {

        /**
         * 数据库类型：h2、mysql
         */
        private String dbType = "h2_mem";

        private String driver;
        private String url;
        @JSONField(serialize = false)
        private String username;
        @JSONField(serialize = false)
        private String password;

        public String getDbType() {
            return dbType;
        }

        public void setDbType(String dbType) {
            this.dbType = dbType;
        }

        public String getDriver() {
            return driver;
        }

        public void setDriver(String driver) {
            this.driver = driver;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }
    }

    public static  class ClusterConfig {

        private String tcpDiscoverySpiLocalPort;
        private String tcpCommunicationSpiLocalPort;

        private List<String> addresses;

       private String workDirectory;


        public String getTcpDiscoverySpiLocalPort() {
            return tcpDiscoverySpiLocalPort;
        }


        public void setTcpDiscoverySpiLocalPort(String tcpDiscoverySpiLocalPort) {
            this.tcpDiscoverySpiLocalPort = tcpDiscoverySpiLocalPort;
        }

        public String getTcpCommunicationSpiLocalPort() {
            return tcpCommunicationSpiLocalPort;
        }


        public void setTcpCommunicationSpiLocalPort(String tcpCommunicationSpiLocalPort) {
            this.tcpCommunicationSpiLocalPort = tcpCommunicationSpiLocalPort;
        }

        public List<String> getAddresses() {
            return addresses;
        }

        public void setAddresses(List<String> addresses) {
            this.addresses = addresses;
        }

        public String getWorkDirectory() {
            return workDirectory;
        }

        public void setWorkDirectory(String workDirectory) {
            this.workDirectory = workDirectory;
        }


    }

    public static class AuthConfig {
        private String username;
        private String password;

        // Getter for username
        public String getUsername() {
            return username;
        }

        // Setter for username
        public void setUsername(String username) {
            this.username = username;
        }

        // Getter for password
        public String getPassword() {
            return password;
        }

        // Setter for password
        public void setPassword(String password) {
            this.password = password;
        }
    }


    public static class UserConfig {
        private String username;
        private String password;

        // Getter for username
        public String getUsername() {
            return username;
        }

        // Setter for username
        public void setUsername(String username) {
            this.username = username;
        }

        // Getter for password
        public String getPassword() {
            return password;
        }

        // Setter for password
        public void setPassword(String password) {
            this.password = password;
        }
    }

    public static class NodeConfig {
        private String type;

        public String getType() {
            return type;
        }


        public void setType(String type) {
            this.type = type;
        }

    }


}
